<?php
App::uses('AppController', 'Controller');

class UsersController extends AppController {

	public $uses = array();
        
        function beforeFilter() {
            parent::beforeFilter();
        }
        
    public function admin_add()
    {
        $this->layout = 'admin';
        
        if ($this->request->is('post')) {
            $this->User->create();
            if ($this->User->save($this->request->data)) {
                $this->Session->setFlash(__('The user has been saved'));
                $this->redirect(array('action' => 'index'));
            } else {
                $this->Session->setFlash(__('The user could not be saved. Please, try again.'));
            }
        }
    }
    
    public function admin_login()
    {
        $this->layout = 'login';
        if ($this->Auth->login())
        {
            $this->redirect($this->Auth->redirect());
        }
        else
        {
            $this->Session->setFlash(__('Invalid username or password, try again'));
        }
    }

    public function admin_logout()
    {
        $this->redirect($this->Auth->logout());
    }
        
}
